#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 1e5 + 10;
int n, d[N], v[N], a[N], m, p[N], L, V;
int ans[N];
struct node{
    int ne, h;
};
int f[N];
inline int read(){
    int s = 0, w = 1;
    char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-')w = -1;
        ch = getchar();
    }
    while(isdigit(ch)){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
int lowbit(int x){
    return x & -x;
}
void modify(int x, int d){
    while(x <= n){
        ans[x] += d;
        x += lowbit(x);
    }
}
int query(int x){
    int s = 0;
    while(x){
        s += ans[x];
        x -= lowbit(x);
    }
    return s;
}
vector<int> e[N];
int in[N];
signed main(){
   // if(system("diff detect.out detect4.ans")){}
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t = read();
    int cn = 0;
    while(t--){
        cn++;
        n = read(), m = read(), L = read(), V = read();
        for(int i = 1; i <= n; i++){
            d[i] = read(), v[i] = read(), a[i] = read();
        }
        int maxp = 0;
        for(int i = 1; i <= m; i++){
            p[i] = read();
            e[i].clear();
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            if(v[i] > V && a[i] >= 0){
                int l = lower_bound(p + 1, p + 1 + m, d[i]) - p;
                e[m].push_back(l - 1);
                ans++;
                continue;
            }
            if(!a[i]){
                continue;
            }
            double x = (V * V - v[i] * v[i]) * 1.0 / (2 * a[i]);
            int l = lower_bound(p + 1, p + 1 + m, d[i]) - p;
            int r = lower_bound(p + 1, p + 1 + m, ceil(1.0 * (x + d[i]))) - p;
            if(r > m || (a[i] < 0 && (double)p[r] > x + d[i]))r--;
            // if(cn == 1){
            //     cout << i << " " << l << " " << r << " " << x + d[i] << endl;
            // }
            if( (a[i] > 0 && double(x + d[i]) < double(p[m])) || (a[i] < 0 && r >= l)){
                ans++;
                e[r].push_back(l - 1);
                in[l - 1]++;
            }
        }
        printf("%lld ", ans);
        int minn = m;
        for(int i = 1; i <= m; i++){
            f[i] = f[i - 1];
            for(auto v : e[i]){
                f[i] = max(f[i], f[v] + 1);
            }
         //   cout << i << "s" << f[i] << endl;
        }
        
        printf("%lld\n", m - f[m]);
    }
    
}
